package org.mobile.makibis.species;

import org.json.JSONObject;
import org.mobile.makibis.util.ContentLoader;

import android.app.Activity;

public class DataGetter extends Activity{
	
		ContentLoader cont = new ContentLoader();
		String makibisURL;
		
		public DataGetter(String makibisURL){
			this.makibisURL = makibisURL;
		}
		
		public int getSpeciesID(String speciesName){
	    	int ID = 0;	
	    	try{
	    		JSONObject s = new JSONObject(cont.loadJSON(makibisURL+"/search/"+speciesName));
	    		ID = Integer.parseInt(s.getString("ID"));			
	    	}catch(Exception e){}
	    	
	    	return ID;
	    }
		
		public JSONObject getSpeciesData(int ID){
			JSONObject object = null;
			try{
				object = new JSONObject(cont.loadJSON(makibisURL + "/speciesinfo/" + ID));
	    	}catch(Exception e){}
	    	return object;
	    }
	    
	   
		   
}
